package com.controller;

import com.domain.DTO.FlightOrderDto;
import com.domain.VO.FlightOrderVo;
import com.domain.assembler.FlightOrderAssembler;
import com.service.IFlightOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import com.common.result.ResponseResultAdvice;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 大忽悠
 * @create 2022/9/15 11:09
 */
@Validated
@RestController
@RequestMapping("/flightOrder")
@RequiredArgsConstructor
@ResponseResultAdvice
@Api(tags="航班订单")
public class FlightOrderController {
    private final FlightOrderAssembler flightOrderAssembler;
    private final IFlightOrderService iFlightOrderService;

    @ApiOperation("根据用户ID查询订单信息")
    @GetMapping("/list")
    public List<FlightOrderDto> getFlightOrderInfoByUserId(@RequestParam("uid")Integer uid){
        return flightOrderAssembler.getFlightOrderInfoByUserId(uid);
    }


    @ApiOperation("用户买票")
    @PostMapping("buy")
    public FlightOrderDto buyFlightTicket(FlightOrderVo flightOrderVo){
        return iFlightOrderService.buyFlightTicket(flightOrderVo);
    }
}
